package top.anydata.lifeofcode.lifesystem.web.controller.api.user;

import com.alibaba.fastjson.JSON;
import jakarta.validation.Valid;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import top.anydata.lifeofcode.lifesystem.service.app.IAppUserService;
import top.anydata.lifeofcode.lifesystem.web.requests.api.AppUserSignupRequest;
import top.anydata.lifeofcode.lifesystem.web.responses.admin.ApiResponse;

/**
 * 功能描述: App 用户管理相关.
 *  约定/app/{appid} appid在app后.
 * @author <a href="mailto:caingao@anydata.top">CainGao</a>
 * @version V_1.0
 * @date 2024/5/8 2:06 PM
 */
@Slf4j
@RestController
@RequestMapping("/app/{appid}/user")
public class AppUserAuthController {

    IAppUserService appUserService;

    public AppUserAuthController(IAppUserService appUserService) {
        this.appUserService = appUserService;
    }

    /**
     * 注册流程
     */
    @PostMapping("/signup")
    public ResponseEntity<String> signup(@PathVariable String appid,
                                         @RequestBody @Valid AppUserSignupRequest appUserSignupRequest) {
        log.info("appid:{},appUserSignupRequest:{}", appid, JSON.toJSONString(appUserSignupRequest));

        return ResponseEntity.ok("");
    }

    /**
     * 登录流程
     */
    @PostMapping("/signin")
    public ResponseEntity<ApiResponse<String>> signin(@PathVariable String appid) {

        return ResponseEntity.ok(ApiResponse.success(""));
    }

    @GetMapping("/location")
    public ResponseEntity<ApiResponse<String>> location(@RequestBody String body){
        log.info(body);
        return ResponseEntity.ok(ApiResponse.success(""));
    }

}
